package xx.iverson.listening_manager.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import xx.iverson.listening_manager.interceptor.LoginInterceptor;

import javax.annotation.Resource;

/**
 * xx.iverson.config.WebMvcConfig
 * 描述：
 * on 2025/10/16-下午5:39
 *
 * @author weijx
 */

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截后台管理接口，排除登录接口
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/api/**")
                .excludePathPatterns("/api/sys/login")
                .excludePathPatterns("/api/sys/getTitle")
                .excludePathPatterns("/api/category/level1/list")
                .excludePathPatterns("/api/category/level2/list")
                .excludePathPatterns("/api/category/level2/listByCategory")
                .excludePathPatterns("/api/audio/list")
                .excludePathPatterns("/api/audio/listByCategory")
                .excludePathPatterns("/api/audio/play")
                .excludePathPatterns("/api/audio/download")
                .excludePathPatterns("/api/audio/search")
                .excludePathPatterns("/api/audio/file/**");
    }
}